<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OrangeCNC - ARISC firmware documentation: mod_gpio.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">OrangeCNC - ARISC firmware documentation
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('mod_gpio_8c-example.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">mod_gpio.c</div>  </div>
</div><!--header-->
<div class="contents">
<p><b>Usage example 1</b>: single pin toggling:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="mod__gpio_8h.html">mod_gpio.h</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="mod__msg_8h.html">mod_msg.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> <a name="a0"></a><a class="code" href="main_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    <span class="comment">// module init</span></div><div class="line">    <a name="a1"></a><a class="code" href="mod__gpio_8c.html#add17353cd876e503abc3fa755f5baca7">gpio_module_init</a>();</div><div class="line"></div><div class="line">    <span class="comment">// configure pin PA15 (RED led) as output</span></div><div class="line">    <a name="a2"></a><a class="code" href="mod__gpio_8c.html#a0d3aaed2e4c7b9fc6e3619d087c6aac3">gpio_pin_setup_for_output</a>(<a name="a3"></a><a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>,15);</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span>(;;) <span class="comment">// main loop</span></div><div class="line">    {</div><div class="line">        <span class="comment">// PA15 pin toggling</span></div><div class="line">        <span class="keywordflow">if</span> ( <a name="a4"></a><a class="code" href="mod__gpio_8c.html#ad3f870ee59aefb0a99bd6cc4e7d7fd58">gpio_pin_get</a>(<a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>,15) )  <a name="a5"></a><a class="code" href="mod__gpio_8c.html#a6f4fd583d7d2c87e80487e15e9b1565a">gpio_pin_clear</a>(<a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>,15);</div><div class="line">        <span class="keywordflow">else</span>                        <a name="a6"></a><a class="code" href="mod__gpio_8c.html#a23cdd4156dd0a9e343f6cc7e9396d6a2">gpio_pin_set</a>  (<a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>,15);</div><div class="line"></div><div class="line">        gpio_module_base_thread(); <span class="comment">// real update of pin states</span></div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><p><b>Usage example 2</b>: whole port toggling:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;stdint.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="mod__msg_8h.html">mod_msg.h</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="mod__gpio_8h.html">mod_gpio.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> <a class="code" href="main_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    <span class="comment">// module init</span></div><div class="line">    <a class="code" href="mod__gpio_8c.html#add17353cd876e503abc3fa755f5baca7">gpio_module_init</a>();</div><div class="line"></div><div class="line">    <span class="comment">// configure whole port A as output</span></div><div class="line">    uint8_t pin;</div><div class="line">    <span class="keywordflow">for</span> ( pin = 0; pin &lt; <a name="a7"></a><a class="code" href="mod__gpio_8h.html#ac2e2cd93efe24402f7d5630848a3f196">GPIO_PINS_CNT</a>; pin++ )</div><div class="line">    {</div><div class="line">        <a class="code" href="mod__gpio_8c.html#a0d3aaed2e4c7b9fc6e3619d087c6aac3">gpio_pin_setup_for_output</a>(<a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>, pin);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span>(;;) <span class="comment">// main loop</span></div><div class="line">    {</div><div class="line">        <span class="comment">// port A toggling</span></div><div class="line">        <span class="keywordflow">if</span> ( <a name="a8"></a><a class="code" href="mod__gpio_8c.html#a2979b18350aa4ac94e0a9ae8026dc735">gpio_port_get</a>(<a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>) )    <a name="a9"></a><a class="code" href="mod__gpio_8c.html#afdcdd3eb9af000552dc8f1a54b7a659c">gpio_port_clear</a>(<a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>, 0xFFFFFFFF);</div><div class="line">        <span class="keywordflow">else</span>                        <a name="a10"></a><a class="code" href="mod__gpio_8c.html#aba8f0bc9701f36e3048dbefc81518054">gpio_port_set</a>  (<a class="code" href="mod__gpio_8h.html#abc6126af1d45847bc59afa0aa3216b04ae3d8a811f3bf7196f361be4104db68db">PA</a>, 0xFFFFFFFF);</div><div class="line"></div><div class="line">        gpio_module_base_thread(); <span class="comment">// real update of pin states</span></div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><div class="fragment"></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
